package cn.stylefeng.guns.modular.business.controller;

import cn.stylefeng.guns.modular.business.pojo.RiverTransitionRequest;
import cn.stylefeng.guns.modular.business.service.RiverTransitionService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 河道变迁与治理控制器
 *
 * @author zhangyaowen
 * @date 2021/10/08 16:51
 */
@RestController
@ApiResource(name = "河道变迁与治理")
public class RiverTransitionController {

    @Resource
    private RiverTransitionService riverTransitionService;

    /**
     * 添加
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @PostResource(name = "添加", path = "/riverTransition/add")
    public ResponseData add(@RequestBody @Validated(RiverTransitionRequest.add.class) RiverTransitionRequest riverTransitionRequest) {
        riverTransitionService.add(riverTransitionRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @PostResource(name = "删除", path = "/riverTransition/delete")
    public ResponseData delete(@RequestBody @Validated(RiverTransitionRequest.delete.class) RiverTransitionRequest riverTransitionRequest) {
        riverTransitionService.del(riverTransitionRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @PostResource(name = "编辑", path = "/riverTransition/edit")
    public ResponseData edit(@RequestBody @Validated(RiverTransitionRequest.edit.class) RiverTransitionRequest riverTransitionRequest) {
        riverTransitionService.edit(riverTransitionRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @GetResource(name = "查看详情", path = "/riverTransition/detail")
    public ResponseData detail(@Validated(RiverTransitionRequest.detail.class) RiverTransitionRequest riverTransitionRequest) {
        return new SuccessResponseData(riverTransitionService.detail(riverTransitionRequest));
    }

    /**
     * 获取列表
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @GetResource(name = "获取列表", path = "/riverTransition/list")
    public ResponseData list(RiverTransitionRequest riverTransitionRequest) {
        return new SuccessResponseData(riverTransitionService.findList(riverTransitionRequest));
    }


    /**
     * 获取列表（带分页）
     *
     * @author zhangyaowen
     * @date 2021/10/08 16:51
     */
    @GetResource(name = "分页查询", path = "/riverTransition/page")
    public ResponseData page(String name) {
        RiverTransitionRequest riverTransitionRequest = new RiverTransitionRequest();
        riverTransitionRequest.setRiverName(name);
        return new SuccessResponseData(riverTransitionService.findPage(riverTransitionRequest));
    }

    /**
     * 获取河道变迁与治理详情
     *
     * @param id
     * @return
     */
    @GetResource(name = "河道变迁与治理详情", path = "/riverTransition/toReview")
    public ResponseData toReview(String id) {
        return new SuccessResponseData(riverTransitionService.toReview(id));
    }
}